package 环状DNA序列整理.src.main;

public class Main {
    public static String solution(String dna_sequence) {
        // Please write your code here
        String[] representations = new String[dna_sequence.length()];
        for (int i = 0; i < dna_sequence.length(); i++) {
            representations[i] = dna_sequence.substring(i) + dna_sequence.substring(0, i);
        }
        // 然后，找出这些表示法中字典序最小的
        String minRepresentation = representations[0];
        for (String representation : representations) {
            if (representation.compareTo(minRepresentation) < 0) {
                minRepresentation = representation;
            }
        }
        return minRepresentation;
    }

    public static void main(String[] args) {
        // You can add more test cases here
        System.out.println(solution("ATCA").equals("AATC"));
        System.out.println(solution("CGAGTC").equals("AGTCCG"));
        System.out.println(solution("TCATGGAGTGCTCCTGGAGGCTGAGTCCATCTCCAGTAG").equals("AGGCTGAGTCCATCTCCAGTAGTCATGGAGTGCTCCTGG"));
    }
}


